﻿<UserControl x:Class="CredentialsManager.Views.RoleListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ff="clr-namespace:FunctionalFun.UI.Behaviours"
             xmlns:ct="clr-namespace:CredentialsManager.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <DockPanel LastChildFill="True" Style="{StaticResource DisableIfLoadingStyle}">
        <StackPanel DockPanel.Dock="Top" Margin="0, 0, 0, 10">
            <Label FontWeight="Bold">Roles</Label>
            <Label>Filter:</Label>
            <TextBox Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}" />                
        </StackPanel>        
        <WrapPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Content="Add r_ole" Command="{Binding CreateRoleCommand}" Padding="5" Margin="5">
                <Button.ToolTip>
                    <ct:TitledTooltip Title="Add new role"
                                      BodyText="Add a new role to this application (Alt+O)" />
                </Button.ToolTip>
            </Button>
            <Button Content="Delete selec_ted" Command="{Binding Path=DataContext.DeleteRoleCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" 
                    DataContext="{Binding SelectedRoles}" Padding="5" Margin="5" Style="{StaticResource EnableIfItemsSelected}">
                <Button.ToolTip>
                    <ct:TitledTooltip Title="Deleted selected role(s)" 
                                      BodyText="Delete the selected role(s) from this application (Alt+T)" />
                </Button.ToolTip>
            </Button>
        </WrapPanel>
        <ListBox 
            ItemsSource="{Binding Roles}" 
            SelectionMode="Extended" 
            ItemTemplate="{StaticResource RoleDataTemplate}"
            ff:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding SelectedRoles}"/>
    </DockPanel>
</UserControl>
